﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace RSSReader
{
    public partial class frmSetupTimer : Form
    {
        private List<RssChannel> _urlList = null;
        private Timer _timer = null;
        private string _xmlFileName = "";

        public frmSetupTimer()
        {
            InitializeComponent();
            this.Icon = global::RSSReader.Properties.Resources.RSS;
        }

        public DialogResult SetupTimer(ref List<RssChannel> urlList, ref Timer timer, string xmlFileName)
        {
            _urlList = urlList;
            _xmlFileName = xmlFileName;
            _timer = timer;
            txtTimeInterval.Text = ((int)(_timer.Interval / 1000)).ToString();
            this.DialogResult = DialogResult.No;
            return this.ShowDialog();
        }

        private void btnSetup_Click(object sender, EventArgs e)
        {
            if (txtTimeInterval.Text != "")
            {
                _timer.Interval = int.Parse(txtTimeInterval.Text) * 1000;
                RSSFunctions.WriteDataXml(_urlList, _xmlFileName, _timer.Interval);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
    }
}